/**
 * Created by zhaoxi on 2017/12/6.
 */
export default {
    namespace: 'CountModel',
    state: {
        count: 0,
        loading: false
    },
    reducers: {
        change(state) {
            const {count} = state;
            return {
                ...state,
                count: count + 1
            }
        },
        loading(state, {payload}){
            return {
                ...state,
                loading: payload
            }
        }
    },
    asyncTasks: {
        asyncTest({dispatch}, {payload}) {
            dispatch({type: 'CountModel/loading', payload});
            setTimeout(function () {
                dispatch({type: 'CountModel/loading', payload: false});
            }, 1000);
        }
    }
}